package com.bjpowernode.controllers;

import com.bjpowernode.entities.TActivityRemark;
import com.bjpowernode.querys.ActivityRemarkQuery;
import com.bjpowernode.result.Result;
import com.bjpowernode.services.ActivityRemarkService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
public class ActivityRemarkController {
    @Resource
    private final ActivityRemarkService activityRemarkService;

    public ActivityRemarkController(ActivityRemarkService activityRemarkService) {
        this.activityRemarkService = activityRemarkService;
    }

    @PostMapping(value = "/api/activity/remark")
    public Result addActivityRemark(@RequestBody ActivityRemarkQuery activityRemarkQuery) {
        int num = activityRemarkService.saveActivityRemark(activityRemarkQuery);
        return num >= 1 ? Result.OK() : Result.FAIL();
    }

    @GetMapping(value = "/api/activity/remarks")
    public Result getActivityRemarksByPage(@RequestParam(value = "current") Integer current, @RequestParam(value = "activityId") Integer activityId) {
        PageInfo<TActivityRemark> pageInfo = activityRemarkService.getActivityRemarksByPage(current, activityId);
        return Result.OK(pageInfo);
    }

}
